home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / t3_1 / nexttsrc.lha / nexttsources / sources / comp / assembler / as_syntax.t < prev    next >
Encoding:
Text File  |  1988-02-05  |  3.3 KB  |  83 lines

  1. (herald (assembler as_syntax t 0))
  2.  
  3. ;;; Copyright (c) 1985 Yale University
  4. ;;;     Authors: N Adams, R Kelsey, D Kranz, J Philbin, J Rees.
  5. ;;; This material was developed by the T Project at the Yale University Computer 
  6. ;;; Science Department.  Permission to copy this software, to redistribute it, 
  7. ;;; and to use it for any purpose is granted, subject to the following restric-
  8. ;;; tions and understandings.
  9. ;;; 1. Any copy made of this software must include this copyright notice in full.
  10. ;;; 2. Users of this software agree to make their best efforts (a) to return
  11. ;;;    to the T Project at Yale any improvements or extensions that they make,
  12. ;;;    so that these may be included in future releases; and (b) to inform
  13. ;;;    the T Project of noteworthy uses of this software.
  14. ;;; 3. All materials developed as a consequence of the use of this software
  15. ;;;    shall duly acknowledge such use, in accordance with the usual standards
  16. ;;;    of acknowledging credit in academic research.
  17. ;;; 4. Yale has made no warrantee or representation that the operation of
  18. ;;;    this software will be error-free, and Yale is under no obligation to
  19. ;;;    provide any services, by way of maintenance, update, or otherwise.
  20. ;;; 5. In conjunction with products arising from the use of this material,
  21. ;;;    there shall be no use of the name of the Yale University nor of any
  22. ;;;    adaptation thereof in any advertising, promotional, or sales literature
  23. ;;;    without prior written consent from Yale in each case.
  24. ;;;
  25.  
  26. ;;; Declarations for AS clients - i.e. machine description
  27. ;;; writers.  AS also presents an interface to the fore
  28. ;;; (as opposed to aft) end of the compiler.  That interface
  29. ;;; is partially described by the file AS.T; and partially
  30. ;;; described by the particular machine description being used.
  31.                                                                               
  32. ;;; FG_SPEC
  33. (define-syntax (define-fg bvl . specs)
  34.   `(define ,(car bvl) (named-fg ,bvl ,@specs)))
  35.  
  36. (define-syntax (named-fg bvl . specs)
  37.   (process-define-fg (car bvl) (cdr bvl) specs))
  38.  
  39. (define-syntax (define-data-fg bvl . specs)
  40.   `(define ,(car bvl) (named-data-fg ,bvl ,@specs)))
  41.  
  42. (define-syntax (named-data-fg bvl . specs)
  43.   (process-define-data-fg (car bvl) (cdr bvl) specs))
  44.  
  45. ;;; Pseudo op definition
  46.  
  47. ;;; Given specs list, return an alist of (symbol . proc)
  48. ;;; where proc will do the body of the spec corresponding
  49. ;;; to the symbol.
  50.  
  51. (define-syntax (pseudos-alist . specs)
  52.     ``(,@(list ,@(map (lambda (spec)
  53.                    ``(,',(caar spec) . ,,(make-lap-syntaxer spec)))
  54.                specs))))
  55.  
  56.  
  57. ;;; Form is ((name . vars) . body)
  58. ;;; body should return something that can be passed to the enclosing 
  59. ;;;   fg constructor.
  60.  
  61. (define (make-lap-syntaxer form)
  62.   (let ((parameter-name (generate-symbol 'lap-syntax)))
  63.     `(lambda (,parameter-name)
  64.         (destructure ((,(car form) ,parameter-name))
  65.             ,@(cdr form)))))
  66.  
  67. ;;; Utility
  68.  
  69. ;;; define-fg expands into code with uses of VECTOR
  70. (define-syntax (vector . l)
  71.   (let ((vname (generate-symbol 'vector)))
  72.     `(let ((,vname (make-vector ,(length l))))
  73.        ,@(do ((i 0 (fx+ i 1))
  74.               (elts l (cdr elts))
  75.               (sets '() (cons `(set (vref ,vname ,i) ,(car elts))
  76.                               sets)))
  77.              ((null? elts)
  78.               (reverse! sets)))
  79.        ,vname)))
  80.  
  81.  
  82.  
  83.